package cn.mianxZY6;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Student {
    private int stID;
    private String name;
    private int age;
    private String gender;
    private String hobby;

    public static List<Student> stuList=new ArrayList<Student>();

    static Scanner input=new Scanner(System.in);


    public Student()
    {

    }
    public Student(int stID,String name,int age,String gender,String hobby)
    {
        this.stID=stID;
        this.name=name;
        this.age=age;
        this.gender=gender;
        this.hobby=hobby;
    }

    public int getStID() {
        return stID;
    }

    public void setStuNo(int stuNo) {
        this.stID = stuNo;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getHobby() {
        return hobby;
    }

    public void setHobby(String hobby) {
        this.hobby = hobby;
    }

    public void add_stu()
    {
        System.out.println("***********添加学生信息************");
        System.out.print("学号：");
        int stuNo=input.nextInt();
        System.out.print("姓名：");
        String name=input.next();
        System.out.print("年龄：");
        int age=input.nextInt();
        System.out.print("性别：");
        String gender=input.next();
        System.out.print("业余爱好：");
        String hobby=input.next();
        stuList.add(new Student(stuNo,name,age,gender,hobby));
        System.out.println("信息添加成功！");
    }
    public void del_stu()
    {
        System.out.println("*******删除学生信息*******");
        System.out.print("请输入您要删除的学生学号：");
        int stID=input.nextInt();
        boolean stuFind=false;
        for(Student stu:stuList)
        {
            if(stu.getStID()==stID)
            {
                stuFind=true;
                stuList.remove(stu);
                System.out.println("删除成功！");
                break;
            }
        }
        if(stuFind==false)
        {
            System.out.println("您要删除的学生不存在！！");
        }
    }
    public void printShow()
    {
        int i=0;
        System.out.println("***全部人员信息***");
        for(Student stu:stuList)
        {
            i++;
            System.out.println("第"+i+"个学生信息：");
            System.out.println("学号："+stu.getStID());
            System.out.println("姓名："+stu.getName());
            System.out.println("性别："+stu.getGender());
            System.out.println("年龄："+stu.getAge());
            System.out.println("爱好："+stu.getHobby());

        }
    }
}

